<!DOCTYPE html>
<html>
<head th:include="common/header_css::header('霸王餐小程序后台管理-虚拟币表流水表','%')"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div th:replace="common/toolbar::toolbar('虚拟币表流水表管理')"></div>
        <div th:replace="common/search::search('%add')"></div>
    </div>
</div>

<!--添加XnbiFlow模态框-->
<div id="modal-add-form" class="modal fade" aria-hidden="true">
    <div class="modal-dialog" style="width: 800px;">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <h3 class="m-t-none m-b">虚拟币表流水表添加</h3>
                    <div class="col-sm-12">
                        <div class="ibox float-e-margins">
                            <div class="ibox-content">
                                <form id="aform" method="post" class="form-horizontal" action="add"
                                      onsubmit="return checkAdd()">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">流水号</label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="sn"
                                                           type="text" maxlength="30"/>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">积分数 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="num"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">获取类型</label>
                                                <div class="col-sm-8">
                                                    <select class="form-control" name="jftype">
                                                        <option value="">请选择</option>
                                                        <option value="1">注册</option>
                                                        <option value="2">兑换</option>
                                                        <option value="3">分享</option>
                                                        <option value="4">抵扣</option>
                                                        <option value="5">签到</option>
                                                        <option value="6">赠送</option>
                                                        <option value="7">购物</option>
                                                        <option value="8">过期</option>
                                                        <option value="9">充值</option>
                                                        <option value="10">退款</option>
                                                        <option value="11">获赠积分</option>
                                                        <option value="13">做任务</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">是否确认</label>
                                                <div class="col-sm-8">
                                                    <input type="checkbox" class="js-switch" name="isConfirm"
                                                           value="-1">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">确认时间
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="date" class="form-control selectData" readonly
                                                           id="confirmDate" name="confirmDate">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">生效起始时间
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="date" class="form-control selectData" readonly
                                                           id="dateStart" name="dateStart">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">生效截止时间
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="date" class="form-control selectData" readonly
                                                           id="dateEnd" name="dateEnd">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">有效状态 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="checkbox" class="js-switch" name="state" value="-1">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">备注</label>
                                                <div class="col-sm-10">
                                                            <textarea class="form-control" name="remark" maxlength="500"
                                                            ></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-4 col-sm-offset-2">
                                            <button class="btn btn-primary" type="submit">保存内容</button>
                                            <button data-toggle="modal" type="button" class="btn btn-white"
                                                    href="#modal-add-form">取消
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--修改XnbiFlow模态框-->
<div id="modal-form" class="modal fade" aria-hidden="true">
    <div class="modal-dialog" style="width: 800px;">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <h3 class="m-t-none m-b">虚拟币表流水表修改</h3>
                    <div class="col-sm-12">
                        <div class="ibox float-e-margins">
                            <div class="ibox-content">
                                <form id="mform" method="post" class="form-horizontal" action="modify"
                                      onsubmit="return checkModify()">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">流水号</label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="sn" name="sn"
                                                           type="text" maxlength="30"/>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">积分数 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="num" name="num"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">获取类型</label>
                                                <div class="col-sm-8">
                                                    <select class="form-control" name="jftype" id="jftype">
                                                        <option value="">请选择</option>
                                                        <option value="1">注册</option>
                                                        <option value="2">兑换</option>
                                                        <option value="3">分享</option>
                                                        <option value="4">抵扣</option>
                                                        <option value="5">签到</option>
                                                        <option value="6">赠送</option>
                                                        <option value="7">购物</option>
                                                        <option value="8">过期</option>
                                                        <option value="9">充值</option>
                                                        <option value="10">退款</option>
                                                        <option value="11">获赠积分</option>
                                                        <option value="13">做任务</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">是否确认</label>
                                                <div class="col-sm-8">
                                                    <input type="checkbox" id="isConfirm" name="isConfirm" value="-1">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">确认时间</label>
                                                <div class="col-sm-8">
                                                    <input type="text" class="form-control selectData" readonly
                                                           id="confirmDate2" name="confirmDate">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">生效起始时间</label>
                                                <div class="col-sm-8">
                                                    <input type="text" class="form-control selectData" readonly
                                                           id="dateStart2" name="dateStart">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">生效截止时间</label>
                                                <div class="col-sm-8">
                                                    <input type="text" class="form-control selectData" readonly
                                                           id="dateEnd2" name="dateEnd">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">有效状态 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="checkbox" id="state" name="state" value="-1">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">备注</label>
                                                <div class="col-sm-10">
                                                            <textarea id="remark" name="remark" class="form-control"
                                                                      maxlength="500"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-4 col-sm-offset-2">
                                            <button class="btn btn-primary" type="submit">保存内容</button>
                                            <button data-toggle="modal" type="button" class="btn btn-white"
                                                    href="#modal-form">取消
                                            </button>
                                        </div>
                                    </div>
                                    <input id="id" name="id" type="hidden" value=""/>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="common/footer_js::footer"></div>
<script>
    //图片上传
    function sendFile(file, editor, $editable) {

        var filename = false;
        try {
            filename = file['name'];
        } catch (e) {
            filename = false;
        }
        if (!filename) {
            $(".note-alarm").remove();
        }
        //以上防止在图片在编辑器内拖拽引发第二次上传导致的提示错误
        data = new FormData();
        data.append("mfile", file);
        data.append("key", filename); //唯一性参数

        $.ajax({
            data: data,
            type: "POST",
            url: "/upload/file?type=sn_XnbiFlow",
            cache: false,
            contentType: false,
            processData: false,
            success: function (e) {
                console.log(e)
                if (e && e.code != 0) {
                    swal({title: "上传失败", text: "", type: "error"})
                    return;
                } else {
                    swal({title: "上传成功", text: "", type: "success"})
                }
                editor.insertImage($editable, e.data);
                setTimeout(function () {
                    $(".note-alarm").remove();
                }, 5000);
            },
            error: function () {
                swal({title: "上传失败", text: "", type: "error"})
                return;
            }
        });
    }

    $(document).ready(function () {
        $(".summernote").summernote({
            lang: "zh-CN",
            width: 535,
            height: 260,
            dialogsInBody: true,
            onImageUpload: function (files, editor, $editable) {
                sendFile(files[0], editor, $editable);
            }
        })
    });
</script>
<script src="/js/admin/xnbiflow.js"></script>
</body>
</html>
